package com.acwebsitedesign.uRateDrugs.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.acwebsitedesign.uRateDrugs.domain.Review;
import com.acwebsitedesign.uRateDrugs.domain.ReviewService;
import com.acwebsitedesign.uRateDrugs.domain.Account;
import com.acwebsitedesign.uRateDrugs.domain.AccountService;

@Controller
public class AccountAdminController {
	
	@Autowired
	ReviewService reviewService;
	@Autowired
	AccountService accountService;
	
	@RequestMapping("/getUserInfo.html")
	public ModelAndView getUserInfo() {
		ModelAndView mav = new ModelAndView("getUserInfo");
		return mav;
	}
	
	@RequestMapping("/getAUsersID.html")
	public ModelAndView getAUsersID(@RequestParam int id){
	
	Account account = accountService.getUserById(id);
	ModelAndView mav = new ModelAndView("getAUsersID");
	mav.addObject(account);
	return mav;
	}
	
	
	@RequestMapping("/getAllReviewsFromUser.html")
	public ModelAndView getAllReviewsFromUser(@RequestParam int id){
	
	List <Review> reviewList = reviewService.getAllReviewsFromAUser(id);
	ModelAndView mav = new ModelAndView("AllReviewsFromAUser");
	mav.addObject("reviewList", reviewList);
	return mav;
	}
	
	@RequestMapping("/removeUserByName.html")
	public ModelAndView removeUserByName(@RequestParam String username){
		
		accountService.removeUserByName(username);
		ModelAndView mav = new ModelAndView("removeUserComplete");
		return mav;
	}
}